<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style-type: none;
        }
        li {
            height: 30px;
            width: 100px;
            background-color: #ccc;
            margin: 2px 0px;
            line-height: 30px;
            font-weight: 600;
            text-align: center;
        }
        ul {
            display: flex;
            justify-content: space-around;
            align-items: flex-start;
            flex-direction:row;
        }
        #box {
            border: 1px solid brown;
            height: 240px;
            width: 310px;
            margin: 0 auto;
        }
        .box {
            border: 1px solid brown;
            height: 200px;
            width: 305px;
            margin: 0 auto;
        }
        .topShow {
            display: block;
            background-color: rgba(165, 42, 42, 0.8);
        }
        p {
            display: none;
        }
        .show {
            display: block;
        }
    </style>
</head>
<body>
    <div id="box">
        <ul>
            <li class="topShow">一</li>
            <li>二</li>
            <li>三</li>
        </ul>
        <div class="box">
            <p class="show">abc</p>
            <p>1234</p>
            <p>qwe</p>
        </div>
    </div>
    <script>
        // 2.tab选项卡：顶部3个li，分别为列表1/列表2/列表3，紧接着下方是3个内容盒子，点击li对应显示内容盒子里的内容
        const list = document.getElementsByTagName("li")
        const p = document.getElementsByTagName("p")

        for (let i = 0; i <= 2; i++) {
            list[i].onclick = function () {
                for (let j = 0; j <= 2; j++) {
                    list[j].setAttribute("class", "")
                    p[j].removeAttribute("class")
                }
                list[i].setAttribute("class", "topShow")
                p[i].setAttribute("class", "show")
            }
        }


    </script>
</body>
</html>